package com.twq.conversionsparam

/**
 * Created by tangweiqun on 2017/12/3.
 */

class PreferredPrompt(val preference: String)

class PreferredDrink(val preference: String)

object JoesPrefs {
  //implicit object Prompt extends PreferredPrompt("Yes, master> ")

  implicit val prompt = new PreferredPrompt("Yes, master> ")

  implicit val drink = new PreferredDrink("tea")
}

object Greeter {
  def greet(name: String)(implicit prompt: PreferredPrompt,
                          drink: PreferredDrink) = {
    println("Welcome, " + name + ". The system is ready.")
    print("But while you work, ")
    println("why not enjoy a cup of " + drink.preference + "?")
    println(prompt.preference)
  }
}

object ImplicitParameters {
  def main(args: Array[String]): Unit = {

    import JoesPrefs._

    Greeter.greet("Joe")
  }
}




